package com.javabasic.algorithm.leetcode;

/**
 * @author mir.xiong
 * @version 1.0
 * @description
 * @see
 * @since Created by work on 2022/6/23 22:22
 */
public class NumberOfLaserBeamsInABank {


    /**
     * 简化+暴力
     * @param bank
     * @return
     */
    public int numberOfBeams(String[] bank) {
        int len = bank.length;
        int result = 0;
        int upLine = 0;
        int m = bank[0].length();
        int oneNum = 0;
        for (int i = 0; i < len; i++) {
            oneNum = 0;
            for (int j = 0; j < m; j++) {
                if (bank[i].charAt(j) == '1') {
                    oneNum++;
                }
            }

            if (oneNum != 0) {
                result += oneNum * upLine;
                upLine = oneNum;
            }
        }

        return result;
    }
}
